Skip to content

When cast needs a dereference point at full cast#38245

Merged
bors merged 1 commit into
rust-lang:masterfrom
estebank:cast-deref-hint-2
Dec 21, 2016
Merged

When cast needs a dereference point at full cast#38245
bors merged 1 commit into
rust-lang:masterfrom
estebank:cast-deref-hint-2

Conversation

@estebank

@estebank estebank commented Dec 8, 2016

Copy link
Copy Markdown
Contributor

After the fix of #37453 in PR #37369, instead of pointing at only the cast type, point at the full cast span when a cast needs a dereference, as well as assign the error label to the correct span for proper coloring:

error span pointing at the entire cast

instead of

error span pointing at the type of the cast

Move compile-fail test to ui test.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@nikomatsakis

Copy link
Copy Markdown
Contributor

@emilio

Hmm I'm not sure I see this as an improvement...I think I prefer the new span, but I'd prefer the "did you mean *s?" bit to be moved into a Help, so that it doesn't overlap. What do you think @jonathandturner ?

@estebank estebank force-pushed the cast-deref-hint-2 branch 2 times, most recently from 81bd4cb to 096205b Compare December 14, 2016 21:44
After the fix of rust-lang#37453 in PR rust-lang#37369, instead of pointing at only the
cast type, point at the full cast span when a cast needs a dereference:

```
error: casting `&{float}` as `f32` is invalid
  --> ../../../src/test/ui/mismatched_types/cast-rfc0401.rs:81:30
   |
81 |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
   |                              ^^^^^^^^ cannot cast `&{float}` as `f32`
   |
help: did you mean `*s`?
  --> ../../../src/test/ui/mismatched_types/cast-rfc0401.rs:81:30
   |
81 |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
   |                              ^
```

instead of

```
error: casting `&{float}` as `f32` is invalid
  --> ../../../src/test/ui/mismatched_types/cast-rfc0401.rs:81:35
   |
81 |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
   |                              -    ^^^
   |                              |
   |                              |
   |                              did you mean `*s`?
   |                              cannot cast `&{float}` as `f32`
```
@estebank

estebank commented Dec 15, 2016

Copy link
Copy Markdown
Contributor Author

@nikomatsakis I have separated the suggestion to a help as requested:

error: casting `&{float}` as `f32` is invalid
  --> $DIR/cast-rfc0401.rs:81:30
   |
81 |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
   |                              ^^^^^^^^ cannot cast `&{float}` as `f32`
   |
help: did you mean `*s`?
  --> $DIR/cast-rfc0401.rs:81:30
   |
81 |     vec![0.0].iter().map(|s| s as f32).collect::<Vec<f32>>();
   |                              ^

@nikomatsakis

Copy link
Copy Markdown
Contributor

@estebank looks good!

@nikomatsakis

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Dec 19, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 868fb03 has been approved by nikomatsakis

@bors

bors commented Dec 20, 2016

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 868fb03 with merge 13c4e28...

bors added a commit that referenced this pull request Dec 20, 2016
When cast needs a dereference point at full cast

After the fix of #37453 in PR #37369, instead of pointing at only the cast type, point at the full cast span when a cast needs a dereference, as well as assign the error label to the correct span for proper coloring:

<img width="471" alt="error span pointing at the entire cast" src="https://cloud.githubusercontent.com/assets/1606434/21024245/8797fc2e-bd38-11e6-82c1-66c281c656c1.png">

instead of

<img width="471" alt="error span pointing at the type of the cast" src="https://cloud.githubusercontent.com/assets/1606434/21023777/d4814aa6-bd36-11e6-9fc3-b2a0ea5ee15d.png">

Move `compile-fail` test to `ui` test.
@eddyb

eddyb commented Dec 20, 2016

Copy link
Copy Markdown
Contributor

@rust-lang/tools tests failed but homu didn't pick it up.

@bors r- force

@eddyb

eddyb commented Dec 20, 2016

Copy link
Copy Markdown
Contributor

Hmmmmmm let's try this instead (sorry, @estebank, trying to get the bot unstuck).

@eddyb eddyb closed this Dec 20, 2016
@eddyb

eddyb commented Dec 20, 2016

Copy link
Copy Markdown
Contributor

Well that didn't help anything 😞.

@eddyb eddyb reopened this Dec 20, 2016
@brson

brson commented Dec 20, 2016

Copy link
Copy Markdown
Contributor

@bors retry

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r=nikomatsakis

@bors

bors commented Dec 20, 2016

Copy link
Copy Markdown
Collaborator

📌 Commit 868fb03 has been approved by nikomatsakis

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Dec 20, 2016
…atsakis

When cast needs a dereference point at full cast

After the fix of rust-lang#37453 in PR rust-lang#37369, instead of pointing at only the cast type, point at the full cast span when a cast needs a dereference, as well as assign the error label to the correct span for proper coloring:

<img width="471" alt="error span pointing at the entire cast" src="https://cloud.githubusercontent.com/assets/1606434/21024245/8797fc2e-bd38-11e6-82c1-66c281c656c1.png">

instead of

<img width="471" alt="error span pointing at the type of the cast" src="https://cloud.githubusercontent.com/assets/1606434/21023777/d4814aa6-bd36-11e6-9fc3-b2a0ea5ee15d.png">

Move `compile-fail` test to `ui` test.
bors added a commit that referenced this pull request Dec 20, 2016
@bors bors merged commit 868fb03 into rust-lang:master Dec 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants